package com.asiainfo.dacp.datastash.broker.common.repo;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.asiainfo.dacp.datastash.domain.unit.models.DataStashUnit;
import com.asiainfo.dacp.datastash.domain.unit.repos.DataStashUnitRepository;
import com.asiainfo.dacp.datastash.orm.dao.core.DataStashUnitDao;
import com.asiainfo.dacp.datastash.orm.po.core.DataStashUnitPo;

@Repository
public class UnitRepository {
	@Autowired
	private DataStashUnitRepository contextUnitRepo;

	@Autowired
	private DataStashUnitDao unitDao;
	
	
	public List<DataStashUnitPo> allOnlineAndNotRunning() {
		return unitDao.findAllOnlineAndNotRunning();
	}
	
	public List<DataStashUnitPo> allOnline() {
		return unitDao.findByState("1");
	}

	public List<DataStashUnitPo> allOffline() {
		return unitDao.findByState("2");
	}
	
	public DataStashUnit findOne(String unitId){
		return contextUnitRepo.findOne(unitId);
	} 
}
